﻿@model IList<JLPT.Models.Objects.Question>
@using JLPT.Models.Objects
@using JLPT.Common
@{
    ViewBag.Title = "Test";
}
@{
    int counter = 0;
    int subCounter = 0;
    bool isWrong = false;
}
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true, "You have not finished all question !")

    for (int i = 0; i < Model.Count(); i++)
    {
        counter = i+1;
        @Html.HiddenFor(x => x[i].Id)
        
        @Html.QuestionNameTest(counter, Model[i],false)
    
        for (int k = 0; k < Model[i].QuestionSubs.Count(); k++)
        {
            subCounter = k + 1;
            @Html.HiddenFor(x => x[i].QuestionSubs[k].Id)
            @Html.HiddenFor(x => x[i].QuestionSubs[k].QuestionId)

            if (Model[i].QuestionSubs[k].SelectedAnswer == null && ViewBag.Error != null)
            {
                isWrong = true;
            }

            @Html.FormatSub(subCounter, Model[i].QuestionSubs[k], isWrong)

            for (int j = 0; j < Model[i].QuestionSubs[k].QuestionDetails.Count(); j++)
            {
                @Html.HiddenFor(x => x[i].QuestionSubs[k].QuestionDetails[j].Id)
                <label style="cursor:pointer">
                    <div style="margin-left:50px;" onmouseover="this.className = 'subHover'" onmouseout="this.className = 'subOut'">
                        @Html.RadioButtonFor(x => Model[i].QuestionSubs[k].SelectedAnswer, Model[i].QuestionSubs[k].QuestionDetails[j].Id)
                        @Model[i].QuestionSubs[k].QuestionDetails[j].Answer
                    </div>
                </label>
            }
            isWrong = false;
        }
    }
    <p>&nbsp;</p>
    <input type="submit" value="   Finish  " />
}

